Skip to content

Commit 7bc2eec

Browse files
Fix slow push (#1392)
To determine which files are part of a filtered subset, regardless of their potentially changed path a trick is used: The filter is applied and then the inverted filter is applied to the result. The implementation of that trick was to simply chain the filter with the inverted one. However this caused flatten() to create a hughe intermediate representation (something like a cartesian product) that then has to be simplified down again by optimize()/simplify(). While that worked, it was very computationally expensive making push extremly slow in some cases. Now instead of chaining apply() is called twice, avoiding the huge intermediate representation and thus expensive optimization. Change: fix-slow-push
1 parent 7dffff0 commit 7bc2eec

File tree

9 files changed

+18
-69
lines changed

9 files changed

+18
-69
lines changed

josh-core/src/filter/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,11 +1105,8 @@ pub fn unapply<'a>(
11051105
parent_tree: git2::Tree<'a>,
11061106
) -> JoshResult<git2::Tree<'a>> {
11071107
if let Ok(inverted) = invert(filter) {
1108-
let matching = apply(
1109-
transaction,
1110-
chain(invert(inverted)?, inverted),
1111-
parent_tree.clone(),
1112-
)?;
1108+
let filtered = apply(transaction, invert(inverted)?, parent_tree.clone())?;
1109+
let matching = apply(transaction, inverted, filtered)?;
11131110
let stripped = tree::subtract(transaction, parent_tree.id(), matching.id())?;
11141111
let new_tree = apply(transaction, inverted, tree)?;
11151112

@@ -1166,11 +1163,8 @@ fn unapply_workspace<'a>(
11661163
let wsj_file = chain(root, wsj_file);
11671164
let filter = compose(wsj_file, compose(workspace, root));
11681165
let original_filter = compose(wsj_file, compose(original_workspace, root));
1169-
let matching = apply(
1170-
transaction,
1171-
chain(original_filter, invert(original_filter)?),
1172-
parent_tree.clone(),
1173-
)?;
1166+
let filtered = apply(transaction, original_filter, parent_tree.clone())?;
1167+
let matching = apply(transaction, invert(original_filter)?, filtered)?;
11741168
let stripped = tree::subtract(transaction, parent_tree.id(), matching.id())?;
11751169
let new_tree = apply(transaction, invert(filter)?, tree)?;
11761170

tests/proxy/workspace.t

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@
335335
| | `-- f4045367114a7584eefa64b95bb69d7f840aef
336336
| |-- 64
337337
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
338-
| |-- 66
339-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
340338
| |-- 69
341339
| | `-- d753308940fb9a6c60bf04d0b1c7421fd91aba
342340
| |-- 77
@@ -365,8 +363,6 @@
365363
| | `-- 76696a87dd29d841caa7f0d48e2f4e5359d369
366364
| |-- bc
367365
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
368-
| |-- bd
369-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
370366
| |-- be
371367
| | |-- 06ec33a91b8a108bd135b5a42a84292b035d6b
372368
| | `-- 1afe91719c4fb58e09207874905f09858cfb66
@@ -404,6 +400,6 @@
404400
|-- namespaces
405401
`-- tags
406402

407-
96 directories, 84 files
403+
94 directories, 82 files
408404

409405
$ cat ${TESTTMP}/josh-proxy.out

tests/proxy/workspace_create.t

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,7 @@ Note that ws/d/ is now present in the ws
611611
| |-- 40
612612
| | `-- c389b6b248e13f3cb88dcd79467d7396a4489e
613613
| |-- 43
614-
| | |-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
615-
| | `-- c475ca897b62fd739409aee5db69b0c480aa0d
614+
| | `-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
616615
| |-- 46
617616
| | `-- bc1eabe4b2029b9fcb661f0d447d8389d17337
618617
| |-- 47
@@ -622,8 +621,6 @@ Note that ws/d/ is now present in the ws
622621
| | `-- 825dc642cb6eb9a060e54bf8d69288fbee4904
623622
| |-- 4c
624623
| | `-- a9fbf65ee12663ac24db4be4cab10e53d6d6e7
625-
| |-- 4d
626-
| | `-- dbf4f812dbd547947a2511b01985fb7a460eae
627624
| |-- 5b
628625
| | `-- 560252b0c3c6abc5e0327596a49efb15e494cb
629626
| |-- 5e
@@ -634,8 +631,6 @@ Note that ws/d/ is now present in the ws
634631
| |-- 64
635632
| | |-- 6fd2c5bfe156d57ba03f62f2fe735ddbb74e22
636633
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
637-
| |-- 66
638-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
639634
| |-- 6c
640635
| | `-- 68dd37602c8e2036362ab81b12829c4d6c0867
641636
| |-- 6d
@@ -684,8 +679,6 @@ Note that ws/d/ is now present in the ws
684679
| | |-- 269dc50ffcdc1b87664a061926bf9a072a3456
685680
| | |-- a7760c60ac08ecdcac395823637989a4d681a6
686681
| | `-- c31372c5de4fb705ffdcbf5a4ec5c5103231d9
687-
| |-- a9
688-
| | `-- 954d28dd1313fb2d8f20fc11a1106376c2ffae
689682
| |-- b1
690683
| | `-- c3c9b731fea98c82ce8e9286e213fcb033f70d
691684
| |-- b2
@@ -700,8 +693,6 @@ Note that ws/d/ is now present in the ws
700693
| | `-- f9dcf1394d5152de67b115f55f25e4dc0a2398
701694
| |-- bc
702695
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
703-
| |-- bd
704-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
705696
| |-- bf
706697
| | `-- 7841c0db704465dda4b387d5da09694647d188
707698
| |-- c1
@@ -755,6 +746,6 @@ Note that ws/d/ is now present in the ws
755746
|-- namespaces
756747
`-- tags
757748

758-
154 directories, 160 files
749+
150 directories, 155 files
759750

760751
$ cat ${TESTTMP}/josh-proxy.out

tests/proxy/workspace_edit_commit.t

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@
295295
| | `-- cff5ef0fce401a1a33c2ac2713d6356cbc1b15
296296
| |-- 1b
297297
| | `-- 46698f32d1d1db1eaeb34f8c9037778d65f3a9
298+
| |-- 1f
299+
| | `-- 8abd6f6494fc2f715b3c1a39ac2e01ba806938
298300
| |-- 20
299301
| | `-- 31777de79cd7c74834915674377e96d6864cc9
300302
| |-- 22
@@ -337,8 +339,6 @@
337339
| | `-- 7ff045529989036cbd11bc32b2eaf5a8311aea
338340
| |-- 60
339341
| | `-- 5066c26f66fca5a424aa32bd042ae71c7c8705
340-
| |-- 66
341-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
342342
| |-- 6a
343343
| | `-- 80a5b3af9023d11cb7f37bc1f80d1d1805bfdb
344344
| |-- 6c
@@ -387,7 +387,6 @@
387387
| | |-- c8440fe2cd36638ddb6b3505c1e8f2202f6191
388388
| | `-- cfe79e25ecd337b379e7ec06d7939dbcb2f6a0
389389
| |-- bd
390-
| | |-- 495daf53fe6fd641cc91e8208674050f602955
391390
| | `-- 56f16bf42ff74e68cfb7a59869c81920b02b87
392391
| |-- be
393392
| | `-- c9383652a22b8a07acb86d5357a75f988286dc
@@ -433,4 +432,4 @@
433432
|-- namespaces
434433
`-- tags
435434

436-
129 directories, 124 files
435+
129 directories, 123 files

tests/proxy/workspace_in_workspace.t

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,6 @@
397397
| | `-- 5066c26f66fca5a424aa32bd042ae71c7c8705
398398
| |-- 64
399399
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
400-
| |-- 66
401-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
402400
| |-- 68
403401
| | `-- b1430cedd477c8117976bdb8aba3cee8b9aa9e
404402
| |-- 6b
@@ -439,8 +437,6 @@
439437
| | `-- bd62ec41c785d12270e69b9d49f9babe62fcd6
440438
| |-- bc
441439
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
442-
| |-- bd
443-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
444440
| |-- c2
445441
| | `-- d86319b61f31a7f4f1bc89b8ea4356b60c4658
446442
| |-- c5
@@ -474,5 +470,5 @@
474470
|-- namespaces
475471
`-- tags
476472

477-
119 directories, 111 files
473+
117 directories, 109 files
478474

tests/proxy/workspace_modify.t

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,7 @@ Note that ws/d/ is now present in the ws
616616
| |-- 40
617617
| | `-- c389b6b248e13f3cb88dcd79467d7396a4489e
618618
| |-- 43
619-
| | |-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
620-
| | `-- c475ca897b62fd739409aee5db69b0c480aa0d
619+
| | `-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
621620
| |-- 44
622621
| | `-- 625a9b34b1c6747c29903c3e641a4b2e580673
623622
| |-- 46
@@ -628,8 +627,6 @@ Note that ws/d/ is now present in the ws
628627
| | `-- 825dc642cb6eb9a060e54bf8d69288fbee4904
629628
| |-- 4c
630629
| | `-- a9fbf65ee12663ac24db4be4cab10e53d6d6e7
631-
| |-- 4d
632-
| | `-- dbf4f812dbd547947a2511b01985fb7a460eae
633630
| |-- 59
634631
| | `-- 632d8d838ce9390679767c02c6bfe6c0d244a9
635632
| |-- 5a
@@ -643,8 +640,6 @@ Note that ws/d/ is now present in the ws
643640
| |-- 64
644641
| | |-- 6fd2c5bfe156d57ba03f62f2fe735ddbb74e22
645642
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
646-
| |-- 66
647-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
648643
| |-- 6c
649644
| | `-- 68dd37602c8e2036362ab81b12829c4d6c0867
650645
| |-- 6d
@@ -694,8 +689,6 @@ Note that ws/d/ is now present in the ws
694689
| | |-- 1e8a91058875f157ca1246bdc403b88e93cd94
695690
| | |-- 269dc50ffcdc1b87664a061926bf9a072a3456
696691
| | `-- c31372c5de4fb705ffdcbf5a4ec5c5103231d9
697-
| |-- a9
698-
| | `-- 954d28dd1313fb2d8f20fc11a1106376c2ffae
699692
| |-- ab
700693
| | `-- a295fbe181a47f04650542b7d5582fbd983b98
701694
| |-- b1
@@ -709,8 +702,6 @@ Note that ws/d/ is now present in the ws
709702
| | `-- f9dcf1394d5152de67b115f55f25e4dc0a2398
710703
| |-- bc
711704
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
712-
| |-- bd
713-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
714705
| |-- c1
715706
| | `-- 489fc8fd6ae9ac08c0168d7cabaf5645b922fa
716707
| |-- c2
@@ -766,6 +757,6 @@ Note that ws/d/ is now present in the ws
766757
|-- namespaces
767758
`-- tags
768759

769-
163 directories, 163 files
760+
159 directories, 158 files
770761

771762
$ cat ${TESTTMP}/josh-proxy.out

tests/proxy/workspace_modify_chain.t

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,6 @@
396396
| |-- 64
397397
| | |-- 6fd2c5bfe156d57ba03f62f2fe735ddbb74e22
398398
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
399-
| |-- 66
400-
| | `-- ba3cf39148efcb72db4e7b663e4f42247e2273
401399
| |-- 67
402400
| | `-- 48a16f7d9b29607fcd4df93681361a6105a14a
403401
| |-- 69
@@ -440,8 +438,6 @@
440438
| | `-- 0969c65843463b2d0e86fd4c6efcae33012332
441439
| |-- b0
442440
| | `-- 3b5fbc9a12109cd3f5308929e4812b3c998da6
443-
| |-- b7
444-
| | `-- dfc3aee5bd47bcfcf5a40b7964164a2b1e838b
445441
| |-- b8
446442
| | `-- 54e8ec3db62174179b215404936a58f1bb6a79
447443
| |-- b9
@@ -460,8 +456,7 @@
460456
| | |-- 0544cd5f702a9b3418205ec0425c6ae77f9e3e
461457
| | `-- 7c94c08f59302a2b1587a01d4fd1680d7378c9
462458
| |-- d7
463-
| | |-- 330ea337031af43ba1cf6982a873a40b9170ac
464-
| | `-- 94016e24d97a10d550de2384527f80f9fecfc8
459+
| | `-- 330ea337031af43ba1cf6982a873a40b9170ac
465460
| |-- e1
466461
| | `-- 25e6d9f8f9acca5ffd25ee3c97d09748ad2a8b
467462
| |-- e5
@@ -492,6 +487,6 @@
492487
|-- namespaces
493488
`-- tags
494489

495-
124 directories, 120 files
490+
122 directories, 117 files
496491

497492
$ cat ${TESTTMP}/josh-proxy.out | grep VIEW

tests/proxy/workspace_modify_chain_prefix_subtree.t

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ Note that ws/d/ is now present in the ws
469469
| |-- 40
470470
| | `-- c389b6b248e13f3cb88dcd79467d7396a4489e
471471
| |-- 43
472-
| | |-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
473-
| | `-- c475ca897b62fd739409aee5db69b0c480aa0d
472+
| | `-- 52611a9e7c56dfdfeadec043ced6d6ef7a5c33
474473
| |-- 44
475474
| | |-- 625a9b34b1c6747c29903c3e641a4b2e580673
476475
| | `-- edc62d506b9805a3edfc74db15b1cc0bfc6871
@@ -482,8 +481,6 @@ Note that ws/d/ is now present in the ws
482481
| | `-- 825dc642cb6eb9a060e54bf8d69288fbee4904
483482
| |-- 4c
484483
| | `-- a9fbf65ee12663ac24db4be4cab10e53d6d6e7
485-
| |-- 4d
486-
| | `-- dbf4f812dbd547947a2511b01985fb7a460eae
487484
| |-- 5a
488485
| | `-- 8a4b8c1452d54f1ca88454067369112809a4d2
489486
| |-- 5b
@@ -493,8 +490,6 @@ Note that ws/d/ is now present in the ws
493490
| |-- 64
494491
| | |-- 6fd2c5bfe156d57ba03f62f2fe735ddbb74e22
495492
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
496-
| |-- 66
497-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
498493
| |-- 67
499494
| | `-- 12cb1b8c89e3b2272182f140c81aef3b718671
500495
| |-- 6c
@@ -547,8 +542,6 @@ Note that ws/d/ is now present in the ws
547542
| | `-- c31372c5de4fb705ffdcbf5a4ec5c5103231d9
548543
| |-- a4
549544
| | `-- b68220bdf7fb846eb9780f7846a2f4bf7cbcc3
550-
| |-- a9
551-
| | `-- 954d28dd1313fb2d8f20fc11a1106376c2ffae
552545
| |-- ab
553546
| | `-- a295fbe181a47f04650542b7d5582fbd983b98
554547
| |-- b1
@@ -561,8 +554,6 @@ Note that ws/d/ is now present in the ws
561554
| | `-- f9dcf1394d5152de67b115f55f25e4dc0a2398
562555
| |-- bc
563556
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
564-
| |-- bd
565-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
566557
| |-- c1
567558
| | `-- 489fc8fd6ae9ac08c0168d7cabaf5645b922fa
568559
| |-- c2
@@ -606,6 +597,6 @@ Note that ws/d/ is now present in the ws
606597
|-- namespaces
607598
`-- tags
608599

609-
151 directories, 152 files
600+
147 directories, 147 files
610601

611602
$ cat ${TESTTMP}/josh-proxy.out | grep VIEW

tests/proxy/workspace_tags.t

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@
371371
| | `-- 5066c26f66fca5a424aa32bd042ae71c7c8705
372372
| |-- 64
373373
| | `-- d1f8d32b274d8c1eeb69891931f52b6ade9417
374-
| |-- 66
375-
| | `-- b81c71c0ad10acdb2b4df3b04eef8abd79e64b
376374
| |-- 6b
377375
| | `-- e0d68b8e87001c8b91281636e21d6387010332
378376
| |-- 78
@@ -408,8 +406,6 @@
408406
| | `-- bd62ec41c785d12270e69b9d49f9babe62fcd6
409407
| |-- bc
410408
| | `-- 665856e841c4ae4a956483dc57b2ea4cc20116
411-
| |-- bd
412-
| | `-- 495daf53fe6fd641cc91e8208674050f602955
413409
| |-- c2
414410
| | `-- d86319b61f31a7f4f1bc89b8ea4356b60c4658
415411
| |-- c5
@@ -440,6 +436,6 @@
440436
|-- namespaces
441437
`-- tags
442438

443-
109 directories, 101 files
439+
107 directories, 99 files
444440

445441
$ cat ${TESTTMP}/josh-proxy.out

0 commit comments

Comments
 (0)