Commit b247256
object-file: avoid fd seekback by checking object size upfront
In certain scenarios, Git handles writing blobs that exceed
"core.bigFileThreshold" differently by streaming the object directly
into a packfile. When there is an active ODB transaction, these blobs
are streamed to the same packfile instead of using a separate packfile
for each. If "pack.packSizeLimit" is configured and streaming another
object causes the packfile to exceed the configured limit, the packfile
is truncated back to the previous object and the object write is
restarted in a new packfile.
This works fine, but requires the fd being read from to save a
checkpoint so it becomes possible to rewind the input source via seeking
back to a known offset at the beginning. In a subsequent commit, blob
streaming is converted to use `struct odb_write_stream` as a more
generic input source instead of an fd which doesn't provide a mechanism
for rewinding.
For this use case though, rewinding the fd is not strictly necessary
because the inflated size of the object is known and can be used to
approximate whether writing the object would cause the packfile to
exceed the configured limit prior to writing anything. These blobs
written to the packfile are never deltified thus the size difference
between what is written versus the inflated size is due to zlib
compression. While this does prevent packfiles from being filled to the
potential maximum is some cases, it should be good enough and still
prevents the packfile from exceeding any configured limit.
Use the inflated blob size to determine whether writing an object to a
packfile will exceed the configured "pack.packSizeLimit".
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 43eadce commit b247256
1 file changed
+25
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1447 | 1447 | | |
1448 | 1448 | | |
1449 | 1449 | | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
1461 | | - | |
| 1450 | + | |
1462 | 1451 | | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
1466 | 1455 | | |
1467 | 1456 | | |
1468 | 1457 | | |
1469 | 1458 | | |
1470 | 1459 | | |
1471 | 1460 | | |
1472 | | - | |
1473 | 1461 | | |
1474 | 1462 | | |
1475 | 1463 | | |
| |||
1486 | 1474 | | |
1487 | 1475 | | |
1488 | 1476 | | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
1498 | 1480 | | |
1499 | 1481 | | |
1500 | 1482 | | |
| |||
1505 | 1487 | | |
1506 | 1488 | | |
1507 | 1489 | | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
1516 | 1490 | | |
1517 | 1491 | | |
1518 | 1492 | | |
| |||
1529 | 1503 | | |
1530 | 1504 | | |
1531 | 1505 | | |
1532 | | - | |
1533 | 1506 | | |
1534 | 1507 | | |
1535 | 1508 | | |
| |||
1605 | 1578 | | |
1606 | 1579 | | |
1607 | 1580 | | |
1608 | | - | |
1609 | 1581 | | |
1610 | 1582 | | |
1611 | 1583 | | |
1612 | 1584 | | |
1613 | 1585 | | |
1614 | 1586 | | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | 1587 | | |
1620 | 1588 | | |
1621 | 1589 | | |
1622 | 1590 | | |
1623 | 1591 | | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
1624 | 1606 | | |
1625 | 1607 | | |
1626 | 1608 | | |
1627 | 1609 | | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
1634 | | - | |
1635 | | - | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
1650 | 1614 | | |
1651 | 1615 | | |
1652 | 1616 | | |
| |||
0 commit comments