Fossil SCM
Cache get_comment_format() result to avoid that the global config db is queried once per timeline row, which brings fossil to a standstill when ~/ is NFS-mounted. Discussion in [forum:9aaefe4e536e01bf].
Commit
6e62c8510fd61716190926595bd985042dfa4bd39a014fa8e3c414b6ab482059
Parent
bb6f23313ed6e48…
1 file changed
+10
-4
+10
-4
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -513,25 +513,31 @@ | ||
| 513 | 513 | ** 3. The global (all-repositories) "comment-format" setting. |
| 514 | 514 | ** 4. The default value COMMENT_PRINT_DEFAULT. |
| 515 | 515 | */ |
| 516 | 516 | int get_comment_format(){ |
| 517 | 517 | int comFmtFlags; |
| 518 | + | |
| 519 | + /* We must cache this result, else | |
| 520 | + ** running the timeline can end up querying the comment-format | |
| 521 | + ** setting from the global db once per timeline entry, which brings | |
| 522 | + ** it to a crawl if that db is network-mounted. Discussed in: | |
| 523 | + ** https://fossil-scm.org/forum/forumpost/9aaefe4e536e01bf */ | |
| 524 | + | |
| 518 | 525 | /* The global command-line option is present, or the value has been cached. */ |
| 519 | 526 | if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 520 | - comFmtFlags = g.comFmtFlags; | |
| 521 | - return comFmtFlags; | |
| 527 | + return g.comFmtFlags; | |
| 522 | 528 | } |
| 523 | 529 | /* Load the local (per-repository) or global (all-repositories) value, and use |
| 524 | 530 | ** g.comFmtFlags as a cache. */ |
| 525 | 531 | comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET); |
| 526 | 532 | if( comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 527 | 533 | g.comFmtFlags = comFmtFlags; |
| 528 | 534 | return comFmtFlags; |
| 529 | 535 | } |
| 530 | 536 | /* Fallback to the default value. */ |
| 531 | - comFmtFlags = COMMENT_PRINT_DEFAULT; | |
| 532 | - return comFmtFlags; | |
| 537 | + g.comFmtFlags = COMMENT_PRINT_DEFAULT; | |
| 538 | + return g.comFmtFlags; | |
| 533 | 539 | } |
| 534 | 540 | |
| 535 | 541 | /* |
| 536 | 542 | ** |
| 537 | 543 | ** COMMAND: test-comment-format |
| 538 | 544 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -513,25 +513,31 @@ | |
| 513 | ** 3. The global (all-repositories) "comment-format" setting. |
| 514 | ** 4. The default value COMMENT_PRINT_DEFAULT. |
| 515 | */ |
| 516 | int get_comment_format(){ |
| 517 | int comFmtFlags; |
| 518 | /* The global command-line option is present, or the value has been cached. */ |
| 519 | if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 520 | comFmtFlags = g.comFmtFlags; |
| 521 | return comFmtFlags; |
| 522 | } |
| 523 | /* Load the local (per-repository) or global (all-repositories) value, and use |
| 524 | ** g.comFmtFlags as a cache. */ |
| 525 | comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET); |
| 526 | if( comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 527 | g.comFmtFlags = comFmtFlags; |
| 528 | return comFmtFlags; |
| 529 | } |
| 530 | /* Fallback to the default value. */ |
| 531 | comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 532 | return comFmtFlags; |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | ** |
| 537 | ** COMMAND: test-comment-format |
| 538 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -513,25 +513,31 @@ | |
| 513 | ** 3. The global (all-repositories) "comment-format" setting. |
| 514 | ** 4. The default value COMMENT_PRINT_DEFAULT. |
| 515 | */ |
| 516 | int get_comment_format(){ |
| 517 | int comFmtFlags; |
| 518 | |
| 519 | /* We must cache this result, else |
| 520 | ** running the timeline can end up querying the comment-format |
| 521 | ** setting from the global db once per timeline entry, which brings |
| 522 | ** it to a crawl if that db is network-mounted. Discussed in: |
| 523 | ** https://fossil-scm.org/forum/forumpost/9aaefe4e536e01bf */ |
| 524 | |
| 525 | /* The global command-line option is present, or the value has been cached. */ |
| 526 | if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 527 | return g.comFmtFlags; |
| 528 | } |
| 529 | /* Load the local (per-repository) or global (all-repositories) value, and use |
| 530 | ** g.comFmtFlags as a cache. */ |
| 531 | comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET); |
| 532 | if( comFmtFlags!=COMMENT_PRINT_UNSET ){ |
| 533 | g.comFmtFlags = comFmtFlags; |
| 534 | return comFmtFlags; |
| 535 | } |
| 536 | /* Fallback to the default value. */ |
| 537 | g.comFmtFlags = COMMENT_PRINT_DEFAULT; |
| 538 | return g.comFmtFlags; |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | ** |
| 543 | ** COMMAND: test-comment-format |
| 544 |